package com.dazzle.core.util.query;


/**
 * 分页类
 */
public class PagingBean{
	
	public static final String PAGING_BEAN="_paging_bean";
	
	public static Integer DEFAULT_PAGE_SIZE=20;
	
	/**
	 * 最多显示页码数
	 */
	public static final int SHOW_PAGES=6;
	
	/**
	 * 每页开始的索引号
	 */
	public Integer start;
	//页码大小
	private Integer pageSize;

	//总记录数
	private Long totalItems;
	
	public PagingBean(int start,int limit){
		this.pageSize=limit;
		this.start=start;
	}

	public Integer getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public Long getTotalItems() {
		return totalItems;
	}

	public Integer getStart() {
		return start;
	}

	public void setStart(Integer start) {
		this.start = start;
	}

	public void setTotalItems(Long totalItems) {
		this.totalItems = totalItems;
	}
	
	public Integer getFirstResult(){
		return start;
	}
	
	public int getCurrentPage(){
		Integer curPage = 1;
		if(this.start>0){
			curPage = this.start/this.pageSize +1;
		}
		return curPage;
	}

	public int getTotalPages(){
		Integer totalPages = 1;
		if(this.totalItems>0){
			totalPages = this.totalItems.intValue()/this.pageSize +1;
		}
		return totalPages;
	}
}
